package br.com.future.dao;

import java.sql.ResultSet;
import java.sql.SQLException;

import org.springframework.jdbc.core.simple.ParameterizedRowMapper;

import br.com.future.domain.User;

public class UserMapper implements ParameterizedRowMapper<User> {

	private static final String USER_ID_COLUMN = "user.id";
	private static final String USER_NAME_COLUMN = "user.name";
	private static final String USER_EMAIL_COLUMN = "user.email";

	/**
	 * Implementations should return the object representation of the current row in the supplied ResultSet.
	 */
	public User mapRow(ResultSet rs, int rowNum) throws SQLException {
		long id = rs.getLong(USER_ID_COLUMN);
		String name = rs.getString(USER_NAME_COLUMN);
		String email = rs.getString(USER_EMAIL_COLUMN);

		return new User(id, name, email);
	}
}
